package system.main;

import models.BufferSize;
import models.EventsType;
import models.GenerationRate;
import models.LogQueueSize;
import models.RealRate;
import models.SubscribeEvents;
import system.events.EventsGenerator;
import system.logger.LogScheduler;
import system.logger.Logger;
import system.notify.Notifier;
import system.wrap_filter.Scheduler;

public class Main {

	private SystemDataStructure ds;
	private EventsType eventsType;
	private RealRate realRate;
	private BufferSize bufferSize;
	private SubscribeEvents subscribeEvents;
	private Scheduler scheduler;
	private Notifier notifyer;
	private LogQueueSize logQueueSize;

	public Main(GenerationRate generationRate) {
		this.ds = new SystemDataStructure();
		ds = new SystemDataStructure();
		scheduler = new Scheduler(ds);
		notifyer = new Notifier(ds);
		realRate = new RealRate();
		eventsType = ds.getEventType();
		bufferSize = new BufferSize();
		subscribeEvents = ds.getSubscribeEvents();
		logQueueSize = new LogQueueSize();
		ds.setGenerationRate(generationRate);

		notifyer.start();
		scheduler.start();
		new EventsGenerator(ds).start();
		int i = 0;
		new LogScheduler(ds).start();
		// while (i < 100) {
		// new Logger(ds).start();
		// i++;
		// }
	}

	public RealRate getRealRate() {
		return realRate;
	}

	public void setRealRate(RealRate realRate) {
		this.realRate = realRate;
	}

	public SystemDataStructure getDs() {
		return ds;
	}

	public void setDs(SystemDataStructure ds) {
		this.ds = ds;
	}

	public EventsType getEventsType() {
		return eventsType;
	}

	public void setEventsType(EventsType eventsType) {
		this.eventsType = eventsType;
	}

	public BufferSize getBufferSize() {
		bufferSize.setSize(ds.getEventBuffer().getSize());
		return bufferSize;
	}

	public void setBufferSize(BufferSize bufferSize) {
		this.bufferSize = bufferSize;
	}

	public SubscribeEvents getSubscribeEvents() {
		return subscribeEvents;
	}

	public void setSubscribeEvents(SubscribeEvents subscribeEvents) {
		this.subscribeEvents = subscribeEvents;
	}

	public Scheduler getScheduler() {
		return scheduler;
	}

	public void setScheduler(Scheduler scheduler) {
		this.scheduler = scheduler;
	}

	public Notifier getNotifyer() {
		return notifyer;
	}

	public void setNotifyer(Notifier notifyer) {
		this.notifyer = notifyer;
	}

	public LogQueueSize getLogQueueSize() {
		logQueueSize.setSize(ds.getLogQueue().getSize());
		return logQueueSize;
	}

	public void setLogQueueSize(LogQueueSize logQueueSize) {
		this.logQueueSize = logQueueSize;
	}

}
